/* GUI CONVERTED from rcvrfsh1.p (converter v1.75) Tue Apr 10 12:06:15 2001 */
/* rcvrfsh1.p - CONFIGURED SHIPPER VERIFICATION                               */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.7.1.8 $                                                         */
/*V8:ConvertMode=Report                                                       */
/* REVISION: 8.6      LAST MODIFIED: 09/20/96   BY: TSI *K005*                */
/* REVISION: 8.6      LAST MODIFIED: 11/27/96   BY: *K02L* Chris Theisen      */
/* REVISION: 8.6      LAST MODIFIED: 14/04/97   BY: Verghese Kurien *K0BK*    */
/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane          */
/* REVISION: 8.6E     LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan         */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan         */
/* REVISION: 9.0      LAST MODIFIED: 03/29/99   BY: *J3BM* Reetu Kapoor       */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane   */
/* REVISION: 9.1      LAST MODIFIED: 06/28/00   BY: *L10M* Ashwini G.         */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KP* Mark Brown         */
/* REVISION: 9.1      LAST MODIFIED: 08/25/00   BY: *N0P0* Arul Victoria      */
/* $Revision: 1.7.1.8 $    BY: Jean Miller         DATE: 03/22/01 ECO: *P008*     */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

/** TO IMPROVE PERFORMANCE   *         */


/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

{mfdeclre.i}
{gplabel.i} /* EXTERNAL LABEL INCLUDE */

/* ********** Begin Translatable Strings Definitions ********* */

&SCOPED-DEFINE rcvrfsh1_p_1 "Level"
/* MaxLen: Comment: */

&SCOPED-DEFINE rcvrfsh1_p_2 "Address"
/* MaxLen: Comment: */

&SCOPED-DEFINE rcvrfsh1_p_3 "PASS/!FAIL"
/* MaxLen: Comment: */

&SCOPED-DEFINE rcvrfsh1_p_4 "Number"
/* MaxLen: Comment: */

&SCOPED-DEFINE rcvrfsh1_p_5 "Program"
/* MaxLen: Comment: */

&SCOPED-DEFINE rcvrfsh1_p_6 "FAIL/PASS"
/* MaxLen: Comment: */

&SCOPED-DEFINE rcvrfsh1_p_7 "Site"
/* MaxLen: Comment: */

&SCOPED-DEFINE rcvrfsh1_p_8 "Seq"
/* MaxLen: Comment: */

/* ********** End Translatable Strings Definitions ********* */

/*INPUT PARAMETERS*/
define input parameter abs_recid as recid no-undo.
define input parameter disp_msg as logical no-undo.
define input parameter disp_rpt as logical no-undo.

/*OUTPUT PARAMETERS*/
define output parameter errors as logical no-undo.

/*LOCAL VARIABLES*/
define variable dock_id as character no-undo.
define variable shipto_id as character no-undo.
define variable cust_id as character no-undo.
define variable site as character no-undo.
define variable address as character no-undo.
define variable suberrors as logical format {&rcvrfsh1_p_6} no-undo.
define variable i as integer no-undo.
define variable j as integer no-undo.
define variable run_file as character no-undo.
define variable l_adref like ad_ref no-undo.

/*SHARED WORKFILES*/
define new shared workfile wf_umsg_det no-undo
   field wf_umsg_site as character
   field wf_umsg_addr as character
   field wf_umsg_nbr as integer
   field wf_umsg_seq as integer
   field wf_umsg_level as integer
   field wf_umsg_exec_pgm as character.

{rcwabsdf.i new}

for first abs_mstr
fields (abs_shipfrom abs_shipto abs__qad05)
where recid(abs_mstr) = abs_recid
no-lock: end.

if not available abs_mstr then
   return.

for first ad_mstr
fields (ad_addr ad_ref ad_type)
where ad_addr = abs_shipto
no-lock: end. /* FOR FIRST AD_MSTR */

/***********************************************************/
/* IF ABS_SHIPTO HAS BEEN TEMPORARILY SET TO MFGUSR BY     */
/* SHIPPER WB, THEN USE THE SHIPTO TEMPORARILY STORED IN   */
/* ABS__QAD05.  YES THIS IS HOKEY.  THE ALTERNATIVE IS TO  */
/* FIND ABS_MSTR WITH EXCLUSIVE-LOCK.                      */
/***********************************************************/
if not available ad_mstr then
for first ad_mstr
fields (ad_addr ad_ref ad_type)
where ad_addr = abs__qad05
no-lock: end. /* FOR FIRST AD_MSTR */

if not available ad_mstr
then do:
   /* ADDRESS DOES NOT EXIST */
   {pxmsg.i &MSGNUM=980 &ERRORLEVEL=4 &MSGARG1=substring(abs_shipto,1,8)}
   pause.
   return.
end. /* if not available ad_mstr */

for first si_mstr
fields (si_site)
where si_site = abs_shipfrom
no-lock: end. /* FOR FIRST SI_MSTR */

if not available si_mstr
then do:
   /* SITE DOES NOT EXIST */
   {pxmsg.i &MSGNUM=708 &ERRORLEVEL=4 &MSGARG1=substring(abs_shipfrom,1,8)}
   pause.
   return.
end. /* if not available si_mstr */

if available ad_mstr
   and ad_type = "customer"
then
   cust_id = ad_addr.

repeat while available ad_mstr
      and ad_type <> "customer":

   assign
      dock_id   = if ad_type = "dock"    then ad_addr else dock_id
      shipto_id = if ad_type = "ship-to" then ad_addr else shipto_id
      cust_id   = if ad_type = "ship-to" then ad_ref  else cust_id.

   l_adref = ad_ref.

   for first ad_mstr
   fields (ad_addr ad_ref ad_type)
   where ad_addr = l_adref
   no-lock: end. /* FOR FIRST AD_MSTR */

end. /* repeat while available ad_mstr */

assign
   site    = "," + abs_shipfrom
   address = "," + cust_id + "," + shipto_id + "," + dock_id.

/***********************************************************/
/* CREATE A SUBSET OF THE UMSG_DET (WF_UMSG_DET) FOR THE   */
/* SHIPPER ADDRESS AND SITE.                               */
/***********************************************************/
{gprun.i ""rcvrf01.p""
   "(input address,
     input site,
     input program-name(1))"}

/***********************************************************/
/* CREATE A SUBSET OF THE ABS_MSTR (WORK_ABS_MSTR) FOR     */
/* JUST THIS SHIPPER.                                      */
/***********************************************************/
{gprun.i ""rcsoisa.p"" "(input abs_recid)"}

for each wf_umsg_det no-lock
by wf_umsg_seq
by wf_umsg_nbr:

   {gprun.i ""gprunck.p""
      "(input wf_umsg_exec_pgm, output run_file)"}

   if run_file <> "" then do:

      if false then do:
         {gprun.i ""rcvrfc01.p""
            "(input wf_umsg_exec_pgm, output run_file)"}
         {gprun.i ""rcvrfc02.p""
            "(input wf_umsg_exec_pgm, output run_file)"}
         {gprun.i ""rcvrfc03.p""
            "(input wf_umsg_exec_pgm, output run_file)"}
         {gprun.i ""rcvrfi01.p""
            "(input wf_umsg_exec_pgm, output run_file)"}
         {gprun.i ""rcvrfi02.p""
            "(input wf_umsg_exec_pgm, output run_file)"}
      end.

      {gprun.i wf_umsg_exec_pgm "(output suberrors)"}

      if suberrors then do:
         errors = if wf_umsg_level > 2
                  then
                     true
                  else
                     errors.

         if disp_msg then do:
            {pxmsg.i &MSGNUM=wf_umsg_nbr &ERRORLEVEL=wf_umsg_level}
            pause.
         end.
      end.

   end.

   else if disp_msg then do:
      /* File does not exist */
      {pxmsg.i &MSGNUM=53 &ERRORLEVEL=4 &MSGARG1=wf_umsg_exec_pgm}
      pause.
   end.

   if disp_rpt then
   do with frame a-shipper-ver:

      if run_file = "" then do:

         suberrors = true.

         for first msg_mstr
         fields (msg_desc msg_lang msg_nbr)
         where msg_lang = global_user_lang
           and msg_nbr  = 53
         no-lock: end. /* FOR FIRST MSG_MSTR */

      end.

      else
      for first msg_mstr
      fields (msg_desc msg_lang msg_nbr)
      where msg_lang = global_user_lang
        and msg_nbr  = wf_umsg_nbr
      no-lock: end. /* FOR FIRST MSG_MSTR */

      /* SET EXTERNAL LABELS */
      setFrameLabels(frame a-shipper-ver:handle).
      display
         wf_umsg_site        label {&rcvrfsh1_p_7}
         wf_umsg_addr        label {&rcvrfsh1_p_2}
         wf_umsg_seq         label {&rcvrfsh1_p_8} format ">>>9"
         wf_umsg_nbr         label {&rcvrfsh1_p_4} format ">>>>9"
         wf_umsg_exec_pgm    label {&rcvrfsh1_p_5} format "x(10)"
         wf_umsg_level       label {&rcvrfsh1_p_1}
         suberrors           column-label {&rcvrfsh1_p_3}
         msg_desc when (available msg_mstr)
      with down frame a-shipper-ver width 132 attr-space STREAM-IO /*GUI*/ .

   end.

end. /* for each wf_umsg_det */
